package com.cssy.yd.logic.dao.impl;

import com.cssy.yd.logic.dao.LogicWhmoveOutwhItemDAO;
import com.cssy.yd.logic.entity.LogicWhmoveOutwhItemDO;
import com.plat.helper.SearchConditions;

import java.util.List;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * 数据访问对象实现类
 * @since 2013-05-23
 */
public class LogicWhmoveOutwhItemDAOImpl extends SqlMapClientDaoSupport implements LogicWhmoveOutwhItemDAO {

    /**
     * 插入数据
     * @param logicWhmoveOutwhItemDO
     * @return 插入数据的主键
     */
    public String insertLogicWhmoveOutwhItemDO(LogicWhmoveOutwhItemDO logicWhmoveOutwhItemDO) throws DataAccessException {
        Object id = getSqlMapClientTemplate().insert("LogicWhmoveOutwhItem.insert", logicWhmoveOutwhItemDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicWhmoveOutwhItemDO
     * @return 查出的记录数
     */
    public Integer countLogicWhmoveOutwhItemDOByExample(LogicWhmoveOutwhItemDO logicWhmoveOutwhItemDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWhmoveOutwhItem.countByDOExample", logicWhmoveOutwhItemDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicWhmoveOutwhItemDO
     * @return 受影响的行数
     */
    public Integer updateLogicWhmoveOutwhItemDO(LogicWhmoveOutwhItemDO logicWhmoveOutwhItemDO) throws DataAccessException {
        int result = getSqlMapClientTemplate().update("LogicWhmoveOutwhItem.update", logicWhmoveOutwhItemDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicWhmoveOutwhItemDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicWhmoveOutwhItemDO> findListByExample(LogicWhmoveOutwhItemDO logicWhmoveOutwhItemDO) throws DataAccessException {
        List<LogicWhmoveOutwhItemDO> list = getSqlMapClientTemplate().queryForList("LogicWhmoveOutwhItem.findListByDO", logicWhmoveOutwhItemDO);
        return list;
    }

    /**
     * 根据主键获取logicWhmoveOutwhItemDO
     * @param id
     * @return logicWhmoveOutwhItemDO
     */
    public LogicWhmoveOutwhItemDO findLogicWhmoveOutwhItemDOByPrimaryKey(String id) throws DataAccessException {
        LogicWhmoveOutwhItemDO logicWhmoveOutwhItemDO = (LogicWhmoveOutwhItemDO) getSqlMapClientTemplate().queryForObject("LogicWhmoveOutwhItem.findByPrimaryKey", id);
        return logicWhmoveOutwhItemDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicWhmoveOutwhItemDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicWhmoveOutwhItem.deleteByPrimaryKey", id);
        return rows;
    }

    @Override
    public List<LogicWhmoveOutwhItemDO> find(SearchConditions scs) throws DataAccessException{
		List<LogicWhmoveOutwhItemDO> list = getSqlMapClientTemplate().queryForList("LogicWhmoveOutwhItem_ex.find", scs);
   		   return list;
    }
    
	@Override
    public Integer count(SearchConditions scs) throws DataAccessException {		
		 Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWhmoveOutwhItem_ex.count", scs);
  	      return count;
  	}
	
	/**
     * 获取对象列表
     * @param SearchConditions
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    @Override
    public List<LogicWhmoveOutwhItemDO> findOnRouteAff(SearchConditions scs) throws DataAccessException{
        List<LogicWhmoveOutwhItemDO> list = getSqlMapClientTemplate().queryForList("LogicWhmoveOutwhItem_ex.findOnRouteAff", scs);
        return list;
    }
    

    /**
     * 获取对象列表条数
     * @param SearchConditions
     * @return 对象列表条数
     */
    @SuppressWarnings("unchecked")
    @Override
    public Integer findOnRouteAffCount(SearchConditions scs) throws DataAccessException{
    	Integer rows = (Integer) getSqlMapClientTemplate().queryForObject("LogicWhmoveOutwhItem_ex.findOnRouteAffCount", scs);
        return rows;
    }

	@Override
	public Integer deleteByLogicWhmoveOutwhDOId(String id)
			throws DataAccessException {
		Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicWhmoveOutwhItem.deleteByOtherOutwhId", id);
	     return rows;
	}
	
	@Override
	public List<LogicWhmoveOutwhItemDO> findListByOutwhId(String otherWhId) {
		List<LogicWhmoveOutwhItemDO> list = getSqlMapClientTemplate().queryForList("LogicWhmoveOutwhItem.findByOutwhId", otherWhId);
		return list;
	}
	
	@Override
	 public Double findFqQuantityByOtheroutwhid(SearchConditions scs) throws DataAccessException {
		Double fqQuantity = (Double) getSqlMapClientTemplate().queryForObject("LogicWhmoveOutwhItem_ex.findFqQuantityByOtheroutwhid", scs);
		return fqQuantity;
	}
}